﻿
MUI.openByPanel=function(title,url){
    MUI.updateContent({
		element: $('workspace'),
		url: url,
		title: title
	});
};

MUI.showModalAlert=function(message,okFunction){
    new MUI.Modal({
		id: 'alertMessage',
		title:'提示信息',
		content: '<table class="tableFixed" border="0" cellpadding="0" cellspacing="0" width="100%" style="height:90px;color:#F00;line-height:25px;text-align:center;"><tr><td valign="center">'+message+'</td></tr></table><div style="height:30px;text-align:right;"><input id="alertOkButton" class="button" type="button" value="确定" /></div>',
		type: 'modal',
		width: 300,
		height:120,
		padding: { top: 0, right: 10, bottom: 0, left: 10 },
		modalOverlayClose:false,
		scrollbars: false,
		closable:false,
		onContentLoaded:function(){
		    $('alertOkButton').addEvent('click',function(){
		        if($defined(okFunction))
		            okFunction();
		        $('alertMessage').retrieve('instance').close();
		    });
		}
	});
};

MUI.showConfirm=function(message,okFunction,backFunction){
    new MUI.Modal({
		id: 'confirmMessage',
		title:'确认信息',			
		content: '<table class="tableFixed" border="0" cellpadding="0" cellspacing="0" width="100%" style="height:90px;color:#F00;line-height:25px;text-align:center;"><tr><td valign="center">'+message+'</td></tr></table><div style="height:30px;text-align:right;"><input id="confirmOkButton" class="button" type="button" value="确定" />&nbsp;&nbsp;<input id="confirmOkBack" class="button" type="button" value="返回" /></div>',
		type: 'modal',
		width: 300,
		height:120,
		padding: { top: 0, right: 10, bottom: 0, left: 10 },
		modalOverlayClose:false,
		scrollbars: false,
		closable:false,
		onContentLoaded:function(){
		    $('confirmOkButton').addEvent('click',function(){
		        if($defined(okFunction))
		            okFunction();
		        $('confirmMessage').retrieve('instance').close();
		    });
		    $('confirmOkBack').addEvent('click',function(){
		        if($defined(backFunction))
		            backFunction();
		        $('confirmMessage').retrieve('instance').close();
		    });
		}
	});
};

MUI.openChildByModalWindow=function(id,title,contentURL,width,height){
    new MUI.Modal({
		id: id,
		title:title,			
		contentURL:contentURL,
		type: 'modal',
		width: width,
		height:height,
		padding: { top: 0, right: 0, bottom: 0, left: 0 },
		modalOverlayClose:false,
		scrollbars: false,
		onContentLoaded:function(){
		}
	});
};

MUI.openContentByModalWindow=function(id,title,container,content,width,height){
    new MUI.Modal({
		id: id,
		title:title,			
		content:content,
		type: 'modal',
		width: width,
		height:height,
		padding: { top: 0, right: 0, bottom: 0, left: 0 },
		modalOverlayClose:false,
		scrollbars: false,
		onContentLoaded:function(){
		    content.show();
		},
		onClose:function(){
		    content.hide();
		    container.grab(content);
		}
	});
};

MUI.openChildByWindow=function(id,title,contentURL,width,height){
    new MUI.Window({
		id: id,
		title: title,
		contentURL: contentURL,
		maximizable:false,
		resizable:false,
		width: width,
		height: height,
		padding: { top: 0, right: 0, bottom: 0, left: 0 },
		onContentLoaded:function(){
		}
	});
};

MUI.openContentByWindow=function(id,title,container,content,width,height){
    new MUI.Window({
		id: id,
		title: title,
		content: content,
		maximizable:false,
		resizable:false,
		width: width,
		height: height,
		padding: { top: 0, right: 0, bottom: 0, left: 0 },
		onContentLoaded:function(){
		    content.show();
		},
		onClose:function(){
		    content.hide();
		    container.grab(content);
		}
	});
};

MUI.showModalMessage=function(message){
    new MUI.Modal({
		id: 'modalMessage',			
		content: '<span style="color:#F00;line-height:30px;">'+message+'</span>',
		type: 'modal',
		headerHeight:0,
		footerHeight:0,
		width: 350,
		height: 30,
		padding: { top: 0, right: 10, bottom: 0, left: 10 },
		modalOverlayClose:false,
		closable:false,
		scrollbars: false
	});
};
MUI.hideModalMessage=function(){
    $('modalMessage').retrieve('instance').close();
};


//message:{'text':'mytext','color':'red'}
MUI.appendStatusMessage=function(message){
    if($('statusBarText'))
    {
        var statusBarText=$('statusBarText');
        if(!statusBarText.retrieve('num'))
            statusBarText.store('num',1);
        statusBarText.set('html',statusBarText.retrieve('num').toString()+'.<span style="color:'+message.color+'">'+message.text+'</span><span style="color:#999999;">('+new Date().toLocaleTimeString()+')</span><br />'+statusBarText.get('html'));
        statusBarText.store('num',statusBarText.retrieve('num')+1);
    }
};


MUI.requireAll=function(loadFunction){
    new MUI.Require({
        js: [
            MUI.path.plugins + 'util/util.js',
            MUI.path.plugins + 'tree/scripts/tree.js',
            MUI.path.plugins + 'zebratable/zebratable.js',
            MUI.path.plugins + 'omnigrid/omnigrid.js',
            MUI.path.plugins + 'formcheck/formcheck.js' 
        ],
        css: [
            MUI.path.plugins + 'tree/css/style.css',
            MUI.path.plugins + 'zebratable/zebratable.css',
            MUI.path.plugins + 'omnigrid/omnigrid.css',
            MUI.path.plugins + 'formcheck/formcheck.css'
        ],
        onload:function(){
            loadFunction();
		}
    });   
};